<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Doxygen: pcl::AdaptiveRangeCoder类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Doxygen
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classpcl_1_1_adaptive_range_coder.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="#pro-types">Protected 类型</a> &#124;
<a href="#pri-attribs">Private 属性</a> &#124;
<a href="classpcl_1_1_adaptive_range_coder-members.html">所有成员列表</a>  </div>
  <div class="headertitle">
<div class="title">pcl::AdaptiveRangeCoder类 参考</div>  </div>
</div><!--header-->
<div class="contents">

<p><b><a class="el" href="classpcl_1_1_adaptive_range_coder.html" title="AdaptiveRangeCoder compression class">AdaptiveRangeCoder</a></b> compression class  
 <a href="classpcl_1_1_adaptive_range_coder.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="entropy__range__coder_8h_source.html">entropy_range_coder.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:add11f912bbcf53bce1c271c22cc11755"><td class="memItemLeft" align="right" valign="top"><a id="add11f912bbcf53bce1c271c22cc11755"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_adaptive_range_coder.html#add11f912bbcf53bce1c271c22cc11755">AdaptiveRangeCoder</a> ()</td></tr>
<tr class="memdesc:add11f912bbcf53bce1c271c22cc11755"><td class="mdescLeft">&#160;</td><td class="mdescRight">Empty constructor. <br /></td></tr>
<tr class="separator:add11f912bbcf53bce1c271c22cc11755"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb9edd9a929d3e6476d6f356cd928f68"><td class="memItemLeft" align="right" valign="top"><a id="aeb9edd9a929d3e6476d6f356cd928f68"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_adaptive_range_coder.html#aeb9edd9a929d3e6476d6f356cd928f68">~AdaptiveRangeCoder</a> ()</td></tr>
<tr class="memdesc:aeb9edd9a929d3e6476d6f356cd928f68"><td class="mdescLeft">&#160;</td><td class="mdescRight">Empty deconstructor. <br /></td></tr>
<tr class="separator:aeb9edd9a929d3e6476d6f356cd928f68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9b059171c1031a890ecde37bf6a716b7"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_adaptive_range_coder.html#a9b059171c1031a890ecde37bf6a716b7">encodeCharVectorToStream</a> (const std::vector&lt; char &gt; &amp;inputByteVector_arg, std::ostream &amp;outputByteStream_arg)</td></tr>
<tr class="memdesc:a9b059171c1031a890ecde37bf6a716b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode char vector to output stream  <a href="classpcl_1_1_adaptive_range_coder.html#a9b059171c1031a890ecde37bf6a716b7">更多...</a><br /></td></tr>
<tr class="separator:a9b059171c1031a890ecde37bf6a716b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63189eb5e8abacd7dc51c21ca29b7b5d"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_adaptive_range_coder.html#a63189eb5e8abacd7dc51c21ca29b7b5d">decodeStreamToCharVector</a> (std::istream &amp;inputByteStream_arg, std::vector&lt; char &gt; &amp;outputByteVector_arg)</td></tr>
<tr class="memdesc:a63189eb5e8abacd7dc51c21ca29b7b5d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode char stream to output vector  <a href="classpcl_1_1_adaptive_range_coder.html#a63189eb5e8abacd7dc51c21ca29b7b5d">更多...</a><br /></td></tr>
<tr class="separator:a63189eb5e8abacd7dc51c21ca29b7b5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-types"></a>
Protected 类型</h2></td></tr>
<tr class="memitem:a83c9735188c1b1f9624b1c4d16b7a0d4"><td class="memItemLeft" align="right" valign="top"><a id="a83c9735188c1b1f9624b1c4d16b7a0d4"></a>
typedef boost::uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>DWord</b></td></tr>
<tr class="separator:a83c9735188c1b1f9624b1c4d16b7a0d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private 属性</h2></td></tr>
<tr class="memitem:a7e52495f021cf6daaa98ecc2e12a0558"><td class="memItemLeft" align="right" valign="top">std::vector&lt; char &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a></td></tr>
<tr class="separator:a7e52495f021cf6daaa98ecc2e12a0558"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p><b><a class="el" href="classpcl_1_1_adaptive_range_coder.html" title="AdaptiveRangeCoder compression class">AdaptiveRangeCoder</a></b> compression class </p>
<dl class="section note"><dt>注解</dt><dd>This class provides adaptive range coding functionality. </dd>
<dd>
Its symbol probability/frequency table is adaptively updated during encoding </dd>
<dd>
</dd></dl>
<dl class="section author"><dt>作者</dt><dd>Julius Kammerl (<a href="#" onclick="location.href='mai'+'lto:'+'jul'+'iu'+'s@k'+'am'+'mer'+'l.'+'de'; return false;">juliu<span style="display: none;">.nosp@m.</span>s@ka<span style="display: none;">.nosp@m.</span>mmerl<span style="display: none;">.nosp@m.</span>.de</a>) </dd></dl>
</div><h2 class="groupheader">成员函数说明</h2>
<a id="a63189eb5e8abacd7dc51c21ca29b7b5d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63189eb5e8abacd7dc51c21ca29b7b5d">&#9670;&nbsp;</a></span>decodeStreamToCharVector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::AdaptiveRangeCoder::decodeStreamToCharVector </td>
          <td>(</td>
          <td class="paramtype">std::istream &amp;&#160;</td>
          <td class="paramname"><em>inputByteStream_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::vector&lt; char &gt; &amp;&#160;</td>
          <td class="paramname"><em>outputByteVector_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode char stream to output vector </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputByteStream_arg</td><td>input stream of compressed data </td></tr>
    <tr><td class="paramname">outputByteVector_arg</td><td>decompressed output vector </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes read from input stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;{</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;  uint8_t ch;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;  DWord freq[257];</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, j, f;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160; </div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;  <span class="comment">// define limits</span></div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  <span class="keyword">const</span> DWord top = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 24;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;  <span class="keyword">const</span> DWord bottom = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  <span class="keyword">const</span> DWord maxRange = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160; </div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;  DWord low, range;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  DWord <a class="code" href="structcode.html">code</a>;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160; </div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> outputBufPos;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> output_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span><span class="keyword">&gt;</span> (outputByteVector_arg.size ());</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160; </div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> streamByteCount;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160; </div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  streamByteCount = 0;</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160; </div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  outputBufPos = 0;</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;  <a class="code" href="structcode.html">code</a> = 0;</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;  low = 0;</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  range = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160; </div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  <span class="comment">// init decoding</span></div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 4; i++)</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;  {</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    <a class="code" href="structcode.html">code</a> = (<a class="code" href="structcode.html">code</a> &lt;&lt; 8) | ch;</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;  }</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160; </div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;  <span class="comment">// init cumulative frequency table</span></div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt;= 256; i++)</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    freq[i] = i;</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160; </div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  <span class="comment">// decoding loop</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; output_size; i++)</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;  {</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    uint8_t symbol = 0;</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;    uint8_t sSize = 256 / 2;</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160; </div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="comment">// map code to range</span></div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    DWord count = (<a class="code" href="structcode.html">code</a> - low) / (range /= freq[256]);</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160; </div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    <span class="comment">// find corresponding symbol</span></div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    <span class="keywordflow">while</span> (sSize &gt; 0)</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    {</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;      <span class="keywordflow">if</span> (freq[symbol + sSize] &lt;= count)</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;      {</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;        symbol = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span> (symbol + sSize);</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;      }</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;      sSize /= 2;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    }</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160; </div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    <span class="comment">// output symbol</span></div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    outputByteVector_arg[outputBufPos++] = symbol;</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160; </div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <span class="comment">// update range limits</span></div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;    low += freq[symbol] * range;</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    range *= freq[symbol + 1] - freq[symbol];</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160; </div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <span class="comment">// decode range limits</span></div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -int (low) &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    {</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;      inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;      streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;      <a class="code" href="structcode.html">code</a> = <a class="code" href="structcode.html">code</a> &lt;&lt; 8 | ch;</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;    }</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160; </div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;    <span class="comment">// update cumulative frequency table</span></div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <span class="keywordflow">for</span> (j = symbol + 1; j &lt; 257; j++)</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;      freq[j]++;</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160; </div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    <span class="comment">// detect overflow</span></div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    <span class="keywordflow">if</span> (freq[256] &gt;= maxRange)</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    {</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;      <span class="comment">// rescale</span></div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;      <span class="keywordflow">for</span> (f = 1; f &lt;= 256; f++)</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;      {</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;        freq[f] /= 2;</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;        <span class="keywordflow">if</span> (freq[f] &lt;= freq[f - 1])</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;          freq[f] = freq[f - 1] + 1;</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;      }</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    }</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;  }</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160; </div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;  <span class="keywordflow">return</span> (streamByteCount);</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160; </div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;}</div>
<div class="ttc" id="astructcode_html"><div class="ttname"><a href="structcode.html">code</a></div><div class="ttdef"><b>Definition:</b> inftrees.h:24</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a9b059171c1031a890ecde37bf6a716b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9b059171c1031a890ecde37bf6a716b7">&#9670;&nbsp;</a></span>encodeCharVectorToStream()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::AdaptiveRangeCoder::encodeCharVectorToStream </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; char &gt; &amp;&#160;</td>
          <td class="paramname"><em>inputByteVector_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::ostream &amp;&#160;</td>
          <td class="paramname"><em>outputByteStream_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode char vector to output stream </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputByteVector_arg</td><td>input vector </td></tr>
    <tr><td class="paramname">outputByteStream_arg</td><td>output stream containing compressed data </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes written to output stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;{</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  DWord freq[257];</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  uint8_t ch;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, j, f;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keywordtype">char</span> out;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="comment">// define limits</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="keyword">const</span> DWord top = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 24;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  <span class="keyword">const</span> DWord bottom = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <span class="keyword">const</span> DWord maxRange = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  DWord low, range;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> readPos;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> input_size;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160; </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  input_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span><span class="keyword">&gt;</span> (inputByteVector_arg.size ());</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;  <span class="comment">// init output vector</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;  <a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.clear ();</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  <a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.reserve (<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * input_size);</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160; </div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  readPos = 0;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160; </div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  low = 0;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  range = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="comment">// initialize cumulative frequency table</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 257; i++)</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    freq[i] = i;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;  <span class="comment">// scan input</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  <span class="keywordflow">while</span> (readPos &lt; input_size)</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  {</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <span class="comment">// read byte</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    ch = inputByteVector_arg[readPos++];</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="comment">// map range</span></div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    low += freq[ch] * (range /= freq[256]);</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    range *= freq[ch + 1] - freq[ch];</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160; </div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <span class="comment">// check range limits</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -int (low) &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    {</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;      out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 24);</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;      <a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    }</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160; </div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="comment">// update frequency table</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keywordflow">for</span> (j = ch + 1; j &lt; 257; j++)</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;      freq[j]++;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160; </div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    <span class="comment">// detect overflow</span></div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">if</span> (freq[256] &gt;= maxRange)</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    {</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;      <span class="comment">// rescale</span></div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;      <span class="keywordflow">for</span> (f = 1; f &lt;= 256; f++)</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      {</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;        freq[f] /= 2;</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        <span class="keywordflow">if</span> (freq[f] &lt;= freq[f - 1])</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;          freq[f] = freq[f - 1] + 1;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;      }</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160; </div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;  }</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160; </div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;  <span class="comment">// flush remaining data</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 4; i++)</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;  {</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 24);</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    <a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    low &lt;&lt;= 8;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  }</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160; </div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;  <span class="comment">// write to stream</span></div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;  outputByteStream_arg.write (&amp;<a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>[0], <a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.size ());</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;  <span class="keywordflow">return</span> (<span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span><span class="keyword">&gt;</span> (<a class="code" href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">outputCharVector_</a>.size ()));</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160; </div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;}</div>
<div class="ttc" id="aclasspcl_1_1_adaptive_range_coder_html_a7e52495f021cf6daaa98ecc2e12a0558"><div class="ttname"><a href="classpcl_1_1_adaptive_range_coder.html#a7e52495f021cf6daaa98ecc2e12a0558">pcl::AdaptiveRangeCoder::outputCharVector_</a></div><div class="ttdeci">std::vector&lt; char &gt; outputCharVector_</div><div class="ttdef"><b>Definition:</b> entropy_range_coder.h:106</div></div>
</div><!-- fragment -->
</div>
</div>
<h2 class="groupheader">类成员变量说明</h2>
<a id="a7e52495f021cf6daaa98ecc2e12a0558"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7e52495f021cf6daaa98ecc2e12a0558">&#9670;&nbsp;</a></span>outputCharVector_</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt;char&gt; pcl::AdaptiveRangeCoder::outputCharVector_</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>vector containing compressed data </p>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li>io/include/pcl/compression/<a class="el" href="entropy__range__coder_8h_source.html">entropy_range_coder.h</a></li>
<li>io/include/pcl/compression/impl/<a class="el" href="entropy__range__coder_8hpp_source.html">entropy_range_coder.hpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>pcl</b></li><li class="navelem"><a class="el" href="classpcl_1_1_adaptive_range_coder.html">AdaptiveRangeCoder</a></li>
    <li class="footer">制作者 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
